<template>
	<div id="app">
		<MainCont></MainCont>
	</div>
</template>

<script>
	import MainCont from './components/v-main.vue'
	export default {
		name: 'app',
		components: {
			MainCont
		},
		created() {
			// beforeunload监听页面刷新事件
			window.addEventListener('beforeunload', this.saveStore)
		},
		destroyed() {
			// 销毁监听刷新事件
			window.removeEventListener('beforeunload', this.saveStore)
		},
		methods: {
			saveStore() {
				// 页面刷新保存当前vuex的状态
				sessionStorage.setItem('store', JSON.stringify(this.$store.state))
			}
		}
	}
</script>

<style scoped>

</style>
